<?php
/**
 * Created by PhpStorm.
 * User: zhao
 * Date: 2018/3/29
 * Time: 17:19
 */

namespace App\Observers;

use App\Models\WxuserStar;
use App\Models\WxuserWxcard;

class WxuserWxCardsObserver
{
    /**
     * 监听记录创建事件.
     *
     * @param  WxuserWxcard  $wxuserWxcard
     * @return void
     */
    public function created(WxuserWxcard $wxuserWxcard)
    {
        WxuserStar::create([
            'id_wxusers'=>$wxuserWxcard->wxusers->id,
            'num'=>-12,
            'wxuser_num_before'=>$wxuserWxcard->wxusers->total_stars,
            'wxuser_num_after'=>$wxuserWxcard->wxusers->total_stars*1-12,
        ]);
    }
}